(defun digits(n)
  (loop for i = n then (floor (/ i 10))
       while (> i 0)
       collect (mod i 10)))

(defun palindromp (n &optional (pos (1- (floor (/ (length n) 2)))))
  (cond ((>= 1 (length n)) t)
	((> 0 pos) t)
	((equal (nth pos n) (nth (1- (- (length n) pos)) n)) (palindromp n (1- pos)))
	(t nil)))

(defun reverse-no(n)
  (loop for i = n then (floor (/ i 10))
     with s = 0
     while (> i 0)
     do (setq s (+ (* s 10)(mod i 10)))
     finally (return s)))

(defun palindromp (n)
  (= n (reverse-no n)))

(defun iter-to-palin (n)
  (loop for i = 1 then (1+ i)
       for x = (+ n (reverse-no n)) then (+ x (reverse-no x))
       for ctr from 1 to 50
       when (palindromp x) do (return i)))

(defun probl55()
  (loop with s = 0 
     for i from 10 to 10000 
     when (not (iter-to-palin i)) 
     do (incf s) 
     finally (return s)))